package com.tairanchina.joat.groovy;

import com.tairanchina.joat.PluginEnvironment;
import com.tairanchina.joat.PluginVariable;
import com.tairanchina.joat.exception.JoatExecuteException;
import com.tairanchina.joat.exception.JoatInstallException;
import com.tairanchina.joat.exception.JoatLifecycleException;

import java.net.URLDecoder;

/**
 * Created by 周靖捷 on 2016/10/10.
 */
public class Test {
    public static void main(String[] args) throws JoatExecuteException, JoatLifecycleException, IllegalAccessException, InstantiationException, ClassNotFoundException, JoatInstallException {
        GroovyPluginManagerDe groovyPluginManager = new GroovyPluginManagerDe(URLDecoder.decode(Test.class.getResource("/").getPath()));
        PluginVariable variable = new PluginVariable();
        variable.put("helloworlds","test");
        PluginEnvironment environment = new PluginEnvironment();
        groovyPluginManager.init();
        groovyPluginManager.run();
        groovyPluginManager.register(new GroovyPluginMeta("com.tairanchina.joat.groovy.DemoGroovyPlugin",true));
        groovyPluginManager.register(new GroovyPluginMeta("com.tairanchina.joat.groovy.DemoDecoratorGroovyPlugin",true));
        groovyPluginManager.getPlugin("com.tairanchina.joat.groovy.DemoGroovyPlugin").get().execute(variable,environment);
        groovyPluginManager.unregister("com.tairanchina.joat.groovy.DemoDecoratorGroovyPlugin");
        groovyPluginManager.getPlugin("com.tairanchina.joat.groovy.DemoGroovyPlugin").get().execute(variable,environment);
    }
}
